<?php
use yii\helpers\Html;
use app_supplier\assets\LoginAssets;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
LoginAssets::register($this);
?>
<?php $this->beginPage() ?>
    <!DOCTYPE html>
    <html lang="<?= Yii::$app->language ?>">
    <head>
        <meta charset="<?= Yii::$app->charset ?>">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <?= Html::csrfMetaTags() ?>
        <title><?= Html::encode($this->title) ?></title>
        <?php $this->head() ?>
    </head>
    <body>
    <?php $this->beginBody() ?>

    <div id="container">
        <div id="header">
            <div class="main-header" style="margin: 10px auto;
position: relative;
height: 117px;
background: url(http://storage.51chebao.com/files/store/logo/bj_store_28.gif) 0px 12px repeat-x;
overflow: hidden;
min-width: 1048px">
                <div>
                    <a href="">
                        <img src="http://storage.51chebao.com/files/store/logo/logo_store_28.png" class="logo"/>
                    </a>
                </div>
                <div id="welcome">
                </div>
            </div>
        </div>
        <div class="page_slice"></div>
        <div class="main-section bg-login">
            <div class="login-box">

                <div class="public-form form-login">
                    <?php $form = ActiveForm::begin([
                        'action'=>Url::to([$this->context->id . '/' . $this->context->action->id]),
                        'id'=>'form_ajax'
                    ])?>
                    <div class="row">
                        <label class="hd">手机号码：</label>
                        <div class="bd">
                            <input type="text" name="account" id="mobile" class="inp-text">
                        </div>
                    </div>
                    <div class="row">
                        <label class="hd">登录密码：</label>
                        <div class="bd">
                            <input type="password" name="password" id="password" class="inp-text" style='width:210px'>
                        </div>
                    </div>
                    <div class="row">
                        <label class="hd">记住密码：</label>
                        <div class="bd">
                            <input type="checkbox" name="rememberMe" id="cache" class="inp-text" value="1" style="width: auto;">
                            <p>&nbsp;</p>
                        </div>
                    </div>
                    <?php if (Yii::$app->session->hasFlash('user_error')):?>
                        <div class="row">
                            <div style="text-align: center">
                                <span style="color: red"><?=Yii::$app->session->getFlash('user_error')?></span>
                            </div>
                        </div>
                    <?php endif;?>
                    <?php ActiveForm::end()?>
                    <div class="opt-area">
                        <button class="btn-submit" style="width:auto;padding: 5px 60px;" id="sub_post" onclick="sub_post()">登 陆</button>

                    </div>
                </div>


            </div>
        </div>
        <div class="split_null"><div class="clear"></div></div>
        <?php $this->endBody() ?>
        <script>
          function sub_post() {
              if (!$("#mobile").val()) {
                  alert('账号不为空');
                  return;
              }
              if (!$("#password").val()) {
                  alert('密码不为空');
                  return;
              }
              var object= $("#form_ajax");
              $.post(object.attr('action'), object.serialize(), function (response) {
                  if (response.status == 200) {
                      location.href = response.url;
                  } else {
                      alert(response.msg);
                  }
              });
          }
        </script>
    </body>
    </html>
<?php $this->endPage() ?>